package com.itheima.demo;

import java.lang.reflect.Constructor;
import java.lang.reflect.Method;

/**
 * @author Zhang_Han
 * @version 1.0
 * @date 2020/7/17 16:58
 */
public class Demo_009 {
    public static void main(String[] args) throws Exception {
        //获取字节码对象;
        Class clazz = Class.forName("com.itheima.domain.Person");

        //获取构造方法 ;
        Constructor constructor = clazz.getConstructor();

        //创建对象 ;
        Object o = constructor.newInstance();

        //获取方法;
        Method method = clazz.getMethod("method", String.class);

        //调用方法 ;
        Object robin = method.invoke(o, "robin");

        System.out.println(robin);
    }
}
